<template>
    <span>
        <template v-if="action == 'edit' ">
            <draw-enclosure v-on="$listeners" v-if="polygonObj.length>0" :value="myValue" @resultPolygon="resultPolygon" :polygonObj="polygonObj" mapHeight="400px"></draw-enclosure>
            <draw-enclosure v-on="$listeners" v-else :value="myValue" @resultPolygon="resultPolygon" mapHeight="400px"></draw-enclosure>
        </template>
        <template v-if="action == 'table'">
            {{value}}
        </template>
    </span>
</template>
<script>
    import drawEnclosure from '../map/drawEnclosure.vue'
    import base from './base.js';

    export default {
        extends: base,
        components: {
            drawEnclosure
        },
        props: {},
        data() {
            return {
                searchModel: 'like',
            }
        },
        computed: {
            polygonObj(){
                if(!this.myValue){
                    return []
                }else{
                    return [{
                            validarea: JSON.parse(this.myValue),
                            id: 0
                        }]
                }
            }
        },
        methods: {
            resultPolygon(data){
                this.myValue = JSON.stringify(data[0].validarea);
            }
        },
    }
</script>
<style>
</style>
